package com.tjbank.cssys.web.controller;

import com.github.pagehelper.PageInfo;
import com.tjbank.cssys.web.service.CkCreditOutCompanyDataService;
import com.tjbank.cssys.web.util.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/ourCompanyData")
public class CkCreditOutCompanyDataController {
    @Autowired
    private CkCreditOutCompanyDataService ckCreditOutCompanyDataService;

    /**
     * 获取委外公司分配的案件数量
     *
     * @param params
     * @param request
     * @return
     */
    @PostMapping("/getOutData")
    public CommonResult getOutCompanyData(@RequestBody Map<String, String> params, HttpServletRequest request) {
        PageInfo pageInfo = ckCreditOutCompanyDataService.getAllotCompanyData(params);
        return CommonResult.success(pageInfo);
    }

    /**
     * 获取公司委外数据详情
     *
     * @param params
     * @param request
     * @return
     */
    @PostMapping("/OutCompanyDataInformation")
    public CommonResult getOutComanyDataInformation(@RequestBody Map<String, String> params, HttpServletRequest request) {
        PageInfo pageInfo = ckCreditOutCompanyDataService.getOutCompanyDataInfomation(params);
        return CommonResult.success(pageInfo);
    }

    /**
     * 修改已经分配好的委外公司数据退到公共池
     *
     * @param params
     * @param request
     * @return
     */
    @PostMapping("/updataCompanyNull")
    public CommonResult updateCompanyNameNull(@RequestBody Map<String, Object> map, HttpServletRequest request) {
        return ckCreditOutCompanyDataService.updateComapnyNameNull(map);
    }

    /**
     * 查询退到公共池中的委外案件
     *
     * @param map
     * @return
     */
    @PostMapping("/getCompanyNull")
    public CommonResult getOutCompanyDataisNull(@RequestBody Map<String, String> map) {
        PageInfo pageInfo = ckCreditOutCompanyDataService.getOutCompanyDataIsNull(map);
        return CommonResult.success(pageInfo);
    }

    /***
     * 获取该类型卡的所有委外公司
     * @param map
     * @return
     */
    @PostMapping("/getCompanyBycaseType")
    public CommonResult getOutCompanyByallotType(@RequestBody Map<String, String> map) {
        return ckCreditOutCompanyDataService.getAllOutComapnyByCaseType(map);
    }

    /**
     * 导出委外数据
     * @param map
     * @return
     */
    @DeleteMapping("/deleteOutData")
    public CommonResult expotOutCompanyData(@RequestBody Map<String, String> map) {
       return ckCreditOutCompanyDataService.exprictOutCompanyData(map);
    }

    /**
     * 撤回委外数据
     * @param map
     * @return
     */
   @RequestMapping("/receiveData")
    public CommonResult  receiveOutCompanyData(@RequestBody Map<String,String>map){
        ckCreditOutCompanyDataService.receivedOutCompanyData(map);
        return CommonResult.success("撤回成功！");
    }

}
